Ext.namespace("Task.Send.History");

Task.Send.History.panel = function() {
	this.exeId;
	this.store = new Ext.data.Store({
		proxy: new Ext.data.HttpProxy({
			url: '../task/searchTaskHistory.form?timesnap=' + Date.parse(new Date())
		}),
		reader: new Ext.data.JsonReader({
			root: 'result',
			totalProperty: 'total',
			//id: 'TASK_ID', // 写毛TASK_ID啊
			fields: ['TASK_ID','ASSIGN_DATE', 'TASK_STATUS','REMARK','FROM_USER_ID','TO_USER_ID']
		}),listeners:{
			 beforeload :{    
	    	  	fn : function(thiz,options){
       	          Ext.apply(thiz.baseParams,
       	          { 
       	          	exeId:this.exeId
       	          });    
              },
              scope:this 
	    	}
		}
	});
	this.renderTaskStatus = function(value){ //这里是子表好伐
		return OMS.TASKSEXESTATUS[value];
	}
	this.colModel = new Ext.grid.ColumnModel({
	    defaults: {
	        width: 100,
	        sortable: true,
	        align: 'center'
	    },
	    columns: [
			{header: '操作时间',width: 200, dataIndex: 'ASSIGN_DATE'},
			{header: '任务状态',width: 120, dataIndex: 'TASK_STATUS',renderer:this.renderTaskStatus},
			{header: '操作说明',width: 200, dataIndex: 'REMARK'},
			{header: '派发人', dataIndex: 'FROM_USER_ID'},
			{header: '接受人', dataIndex: 'TO_USER_ID'}
	    ]
	});
	
	this.gridPanel = new Ext.grid.GridPanel({
		region: 'center',
		cm:this.colModel,
		store:this.store,
		sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
        loadMask: {msg: '加载中，请稍候...'},
        bbar:new Ext.PagingToolbar({
			 pageSize: 30,
	         store: this.store,
	         displayInfo: true,
	         displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
	         emptyMsg: "没有记录..."
		}),
        viewConfig: { forceFit: true }
	})
	Task.Send.History.panel.superclass.constructor.call(this, {
		title:'任务派发历史信息',
		layout:'border',
		items:[this.gridPanel],
		listeners:{
			//render:this.queryTask, // 对你彻底无语了
			activate:this.queryTask
		}
	});
};
Ext.extend(Task.Send.History.panel, Ext.Panel, {
	initFeedBack:function(exeId){
		this.exeId = exeId;
	},
	queryTask :function(exeId){
		this.store.load({
			params:{
				start : 0,
				limit : 30,
				exeId:this.exeId
			}
		})
	}
});


